/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

//如果想用Class.forName方法动态加载这个类,可以用以下类似的代码实现:

/**
 *
 * @author Administrator
 */

public class LoadCat {

    private int age;
    private String name;

    public void LoadCat(String name, int age) {



        this.name = name;

        this.age = age;

    }

    public static void main(String args[]) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        Class clazz = Class.forName("Cat");
        Constructor constructor = clazz.getConstructor(String.class, int.class);
        LoadCat test = (LoadCat) constructor.newInstance("test", 1);
    }
}
